package CollectionDemo;

import java.util.Comparator;

public class PresonComparator implements Comparator<Person> {

	public int compare(Person o1, Person o2) {

		int flag=o1.getNum()-o2.getNum();
		if(o1.getNum()==o2.getNum()) 
		{
			flag=o1.getAge()-o2.getAge();
			if(o1.getAge()==o2.getAge()) 
			{
				if(o1.getName()!=null && o2.getName()!=null && o1.getName().equals(o2.getName()))
				{
					flag=o1.getName().compareTo(o2.getName());
				}
			}
		}
		return flag;
	}

}
